{extend name="base" /}
{block name="content"}
<div class="m-b-md">
    <h2 class="m-b-none">商品列表</h2>
</div>
<div class="row">
    <div class="col-sm-12">
        <section class="panel panel-default">
            <div class="panel-body">
                <table id="MyStretchGrid" class="table table-striped datagrid m-b-sm">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>商品名称</th>
                        <th>价格</th>
                        <th>库存</th>
                        <th>点击数</th>
                        <th>添加时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name='data' item='v'}
                    <tr>
                        <td>{$v['gid']}</td>
                        <td>{$v['gname']}</td>
                        <td>
                            <ul>
                                <li>市场价<del>{$v['market_price']}</del></li>
                                <li>商城价<span>{$v['shop_price']}</span></li>
                            </ul>
                        </td>
                        <td>{$v['stock']}</td>
                        <td>{$v['click']}</td>
                        <td>{:date('Y-m-d H:i:s',$v['time'])}</td>
                        <td>
                            <a href="{:url('Goodslist/index',['gid'=>$v['gid']])}"><i class="fa fa-align-justify"></i></a>
                            <a href="{:url('edit',['gid'=>$v['gid']])}"><i class="fa fa-pencil"></i></a>
                            <a  href="javascript:;" onclick="del({$v['gid']})"><i class="fa fa-times text-danger text"></i></a>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                <!--展示分页-->
                <div class="col-sm-12 text-right text-center-xs">
                    <ul class="pagination pagination-sm m-t-none m-b-none">
                        {$data->render()}
                    </ul>
                </div>

            </div>
        </section>
    </div>
</div>
<script>
    function del(gid) {
        var obj = util.modal({
            title:'确认删除吗?',//标题

            content:'',//内容

            footer:'<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button><button type="button" class="btn btn-danger confirm" data-dismiss="modal">删除</button>',//底部

            width:600,//宽度

            events:{
                confirm:function(){
                    //哪个元素上有.confirm类，被点击就执行这个回调
                    location.href = "{:url('del')}" + '?gid=' + gid;
                }
            }
        });
        //显示模态框
        obj.modal('show');
    }
</script>
{/block}



